/**
 * Copyright © 2012, 2013 dr. ir. Jeroen M. Valk
 * 
 * This file is part of ComPosiX.
 * 
 * ComPosiX is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * ComPosiX is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * ComPosiX. If not, see <http://www.gnu.org/licenses/>.
 */

function TopLayer () {
	function Root() {
		var n = 1;
		cpx.put(fd[1],n);
		cpx.put(fd[3],n);
		cpx.put(fd[5],n);
		cpx.flush(fd[1]);
		cpx.flush(fd[3]);
		cpx.flush(fd[5]);
	}
}

function Layer() {
	function Edge() {
		cpx.get(fd[0],function(n) {
			cpx.put(fd[1],n);
			cpx.put(fd[3],n);
			cpx.put(fd[5],n);
			cpx.flush(fd[1]);
			cpx.flush(fd[3]);
			cpx.flush(fd[5]);
		});
	}
	
	function Internal() {
		cpx.get(fd[0],function(m) {
			cpx.get(fd[4],function(n) {
				cpx.put(fd[1],m+n);
				cpx.put(fd[3],m+n);
				cpx.put(fd[5],m+n);
			});
		});
	}
}